{% extends "base.html" %}

{% block title %}Articles{% endblock title %}

{% block content %}
{% for article in article_list %}
<div class="card">
  <div class="card-header">
    <span class="fw-bold">
      <a href="{{ article.get_absolute_url }}">{{ article.title }}</a>
    </span> &middot;
    <span class="text-muted">by {{ article.author }} |
      {{ article.date }}</span>
  </div>
  <div class="card-body">
    <p>{{ article.body }}</p>
    {% if article.author.pk == request.user.pk %} 
      <a href="{% url 'article_edit' article.pk %}">Edit</a>
      <a href="{% url 'article_delete' article.pk %}">Delete</a>
    {% endif %} 
    <a href="{{ article.get_absolute_url }}">New Comment</a> <!-- new -->
  </div>
  <div class="card-footer">
    {% for comment in article.comment_set.all %}
    <p>
      <span class="fw-bold">
        {{ comment.author }} &middot;
      </span>
      {{ comment }}
    </p>
    {% endfor %}
  </div>
</div>
<br/>
{% endfor %}
{% endblock content %}